package com.wframe.project.jnd.vo;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * Created by lwb on 2017/6/7.
 */
public class CartProductVO implements Cloneable {
    private Integer id;
    private String photo;
    private String name;
    private String b_chanjia;
    private String b_guige;
    private BigDecimal price;
    //分摊后的价格
    private BigDecimal apportionedPrice;
    //购买的商品数量
    private Integer buyNum;
    //买送促销起送的商品数量
    private Integer standardNum;
    //买送促销送的商品数量
    private Integer sendNum;
    //买送赠品数量
    private Integer giftNum;
    //商品总库存
    private Integer amount;
    //单品促销商品可用库存
    private Integer flashSaleAvailableInventory;
    private String unit;
    private Integer cartId;
    private BigDecimal totalPrice;
    private boolean flashSale = false;
    private boolean buySend = false;
    //是否满足条件
    private boolean available = false;
    //赠品是否在页面显示
    private boolean gift = false;
    //赠品类型
    private GiftType giftType;
    //赠品库存是否不足
    private boolean shortage = false;
    private String giftPromotionId;
    //在购物车页面是否选中
    private boolean check;
    //是否常购
    private boolean often;

    private List<String> promotionIds;
    private Map promotionAmount;

    public enum GiftType {
        BUY_SEND,
        PURCHASE_GIFT
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getB_chanjia() {
        return b_chanjia;
    }

    public void setB_chanjia(String b_chanjia) {
        this.b_chanjia = b_chanjia;
    }

    public String getB_guige() {
        return b_guige;
    }

    public void setB_guige(String b_guige) {
        this.b_guige = b_guige;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public BigDecimal getApportionedPrice() {
        return apportionedPrice;
    }

    public void setApportionedPrice(BigDecimal apportionedPrice) {
        this.apportionedPrice = apportionedPrice;
    }

    public Integer getBuyNum() {
        return buyNum;
    }

    public void setBuyNum(Integer buyNum) {
        this.buyNum = buyNum;
    }

    public Integer getStandardNum() {
        return standardNum;
    }

    public void setStandardNum(Integer standardNum) {
        this.standardNum = standardNum;
    }

    public Integer getAmount() {
        return amount;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public Integer getCartId() {
        return cartId;
    }

    public void setCartId(Integer cartId) {
        this.cartId = cartId;
    }

    public BigDecimal getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    }

    public boolean isFlashSale() {
        return flashSale;
    }

    public void setFlashSale(boolean flashSale) {
        this.flashSale = flashSale;
    }

    public boolean isGift() {
        return gift;
    }

    public void setGift(boolean gift) {
        this.gift = gift;
    }

    public Integer getSendNum() {
        return sendNum;
    }

    public void setSendNum(Integer sendNum) {
        this.sendNum = sendNum;
    }

    public boolean isBuySend() {
        return buySend;
    }

    public void setBuySend(boolean buySend) {
        this.buySend = buySend;
    }

    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public String getGiftPromotionId() {
        return giftPromotionId;
    }

    public void setGiftPromotionId(String giftPromotionId) {
        this.giftPromotionId = giftPromotionId;
    }

    public boolean isCheck() {
        return check;
    }

    public void setCheck(boolean check) {
        this.check = check;
    }

    public boolean isOften() {
        return often;
    }

    public void setOften(boolean often) {
        this.often = often;
    }

    public List<String> getPromotionIds() {
        return promotionIds;
    }

    public void setPromotionIds(List<String> promotionIds) {
        this.promotionIds = promotionIds;
    }

    public boolean isShortage() {
        return shortage;
    }

    public void setShortage(boolean shortage) {
        this.shortage = shortage;
    }

    public Map getPromotionAmount() {
        return promotionAmount;
    }

    public void setPromotionAmount(Map promotionAmount) {
        this.promotionAmount = promotionAmount;
    }

    public Integer getGiftNum() {
        return giftNum;
    }

    public void setGiftNum(Integer giftNum) {
        this.giftNum = giftNum;
    }

    public Integer getFlashSaleAvailableInventory() {
        return flashSaleAvailableInventory;
    }

    public void setFlashSaleAvailableInventory(Integer flashSaleAvailableInventory) {
        this.flashSaleAvailableInventory = flashSaleAvailableInventory;
    }


    public GiftType getGiftType() {
        return giftType;
    }

    public void setGiftType(GiftType giftType) {
        this.giftType = giftType;
    }

    public boolean isAvailable() {
        return available;
    }

    public void setAvailable(boolean available) {
        this.available = available;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj != null && obj instanceof CartProductVO) {
            CartProductVO cartProduct = (CartProductVO) obj;
            boolean productIsGift = cartProduct.getGiftType() != null;
            boolean thisIsGift = this.getGiftType() != null;
            if (cartProduct.getId() != null && this.getId() != null && cartProduct.getId().intValue() == this.getId().intValue() && productIsGift == thisIsGift) {
                return true;
            }
        }
        return false;
    }

}
